package CustomerRmi;

import java.rmi.Naming;
import java.rmi.RemoteException;
import POJO.*;

public class CustomerRmi implements RmiInterface{
	RmiInterface rmiInterface;
	
	public void init() {
		try {   
            String url = "//localhost:8806/SAMPLE-SERVER1";   
            rmiInterface = (RmiInterface) Naming.lookup(url);
        } catch (RemoteException rex) {   
            System.out.println("Error in lookup: " + rex.toString());   
        } catch (java.net.MalformedURLException me) {   
            System.out.println("Malformed URL: " + me.toString());   
        } catch (java.rmi.NotBoundException ne) {   
            System.out.println("NotBound: " + ne.toString());   
        }
	}
	
	public void insertCustomer(RegisterPOJO registerPOJO) {
		try {
			rmiInterface.insertCustomer(registerPOJO);
		} catch (RemoteException e) {
			e.printStackTrace();
		}
	}
	public SignInStatePOJO findCustomer(SignInPOJO signInPOJO) {
		try {
			return rmiInterface.findCustomer(signInPOJO);
		} catch (RemoteException e) {
			e.printStackTrace();
		}
		return null;
	}
	public CategoryPOJO findCategory(int i) {
		try {
			return rmiInterface.findCategory(i);
		} catch (RemoteException e) {
			e.printStackTrace();
		}
		return null;
	}
	public BookListPOJO findBookList(int i) {
		try {
			return rmiInterface.findBookList(i);
		} catch (RemoteException e) {
			e.printStackTrace();
		}
		return null;
	}
	public BookListPOJO findBookList(SearchRulePOJO searchRulePOJO) {
		try {
			return rmiInterface.findBookList(searchRulePOJO);
		} catch (RemoteException e) {
			e.printStackTrace();
		}
		return null;
	}
	public PricePOJO findPrice(OrderPOJO orderPOJO) {
		try {
			return rmiInterface.findPrice(orderPOJO);
		} catch (RemoteException e) {
			e.printStackTrace();
		}
		return null;
	}
	public PromotionInfoPOJO findPromotionInfo() {
		try {
			return rmiInterface.findPromotionInfo();
		} catch (RemoteException e) {
			e.printStackTrace();
		}
		return null;
	}
	public void insertOrder(OrderPOJO orderPOJO) {
		try {
			rmiInterface.insertOrder(orderPOJO);
		} catch (RemoteException e) {
			e.printStackTrace();
		}
	}
	public void updateCustomerPromotionInfo(CustomerPromotionInfoPOJO customerPromotionInfoPOJO) {
		try {
			rmiInterface.updateCustomerPromotionInfo(customerPromotionInfoPOJO);
		} catch (RemoteException e) {
			e.printStackTrace();
		}
	}
	public void updateSaleRecord(SaleRecordPOJO saleRecordPOJO) {
		try {
			rmiInterface.updateSaleRecord(saleRecordPOJO);
		} catch (RemoteException e) {
			e.printStackTrace();
		}
	}
	public CollectionPOJO findCollection(String s) {
		try {
			return rmiInterface.findCollection(s);
		} catch (RemoteException e) {
			e.printStackTrace();
		}
		return null;
	}
	public void updateCollection(CollectionPOJO collectionPOJO) {
		try {
			rmiInterface.updateCollection(collectionPOJO);
		} catch (RemoteException e) {
			e.printStackTrace();
		}
	}
	public SaleRecordPOJO findSaleRecord(String s) {
		try {
			return rmiInterface.findSaleRecord(s);
		} catch (RemoteException e) {
			e.printStackTrace();
		}
		return null;
	}
	public OrderListPOJO findOrder(String s) {
		try {
			return rmiInterface.findOrder(s);
		} catch (RemoteException e) {
			e.printStackTrace();
		}
		return null;
	}
}
